package com.bnzj.cloud.gateway.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;

/**
 * @ClassName WebfluxSecurityConfig
 * @Description TODO
 * @Author
 * @Date 2019/9/9
 * @Version V1.0
 **/
@EnableWebFluxSecurity
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
public class OauthResourceConfigurationWebflux {

    @Autowired
    private OauthResourceHttpSecurityAdapterWebflux securityAdapterWebflux;

    @Bean
    public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
        http.csrf().disable();
        securityAdapterWebflux.config(http);
        return http.build();
    }

}
